﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using JM.JCY.BusinessEntity;
using JM.JCY.Proxy;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.Common;
using JM.JCY.Common.Utilities;
using Microsoft.SharePoint;

namespace JM.JCY.SharePointComponent.IncorruptArchives.SelfControlBusinessView
{
    public partial class SelfControlBusinessViewUserControl : UserControl
    {
        public int _caseId
        {
            set { ViewState["_caseId"] = value; }
            get { return (int)ViewState["_caseId"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                using (IncorruptProxy proxy = new IncorruptProxy())
                {
                    if (Request.QueryString["CaseId"] != null)
                    {
                        _caseId = Int32.Parse(Request.QueryString["CaseId"].ToString());
                    }
                    // load data
                    var loadDT = proxy.GetSelfControlBusiness(_caseId, string.Empty);
                    LoadForEdit(loadDT);
                    LoadForView(loadDT);
                }

            }

            // switch controls
            if (this.hfIsEdit.Value != "1")
                SwitchControls(true, false);
            else
                SwitchControls(false, true);
        }

        private void SwitchControls(bool isLabelsShow, bool isControlsShow)
        {
            //Labels
            this.lblDept.Visible = isLabelsShow;
            this.lblFillDate.Visible = isLabelsShow;
            this.lblFiller.Visible = isLabelsShow;
            this.lblPosition.Visible = isLabelsShow;

            this.lblOption1.Visible = isLabelsShow;
            this.lblOption2.Visible = isLabelsShow;
            this.lblOption3.Visible = isLabelsShow;
            this.lblOption4.Visible = isLabelsShow;
            this.lblOption5.Visible = isLabelsShow;
            this.lblOption6.Visible = isLabelsShow;
            this.lblOption7.Visible = isLabelsShow;
            this.lblOption8.Visible = isLabelsShow;
            this.lblOption9.Visible = isLabelsShow;
            this.lblOption10.Visible = isLabelsShow;
            this.lblOption11.Visible = isLabelsShow;
            this.lblOption12.Visible = isLabelsShow;
            this.lblOption13.Visible = isLabelsShow;
            this.lblOption14.Visible = isLabelsShow;
            this.lblOption15.Visible = isLabelsShow;
            this.lblOption16.Visible = isLabelsShow;
            this.lblOption17.Visible = isLabelsShow;
            this.lblOption18.Visible = isLabelsShow;
            this.lblOption19.Visible = isLabelsShow;
            this.lblOption20.Visible = isLabelsShow;
            this.lblOption21.Visible = isLabelsShow;
            this.lblOption22.Visible = isLabelsShow;
            this.lblOption23.Visible = isLabelsShow;
            this.lblOption24.Visible = isLabelsShow;
            this.lblOption25.Visible = isLabelsShow;
            this.lblOption26.Visible = isLabelsShow;
            this.lblOption27.Visible = isLabelsShow;
            this.lblOption28.Visible = isLabelsShow;
            this.lblOption29.Visible = isLabelsShow;
            this.lblOption30.Visible = isLabelsShow;
            this.lblOption31.Visible = isLabelsShow;
            this.lblOption32.Visible = isLabelsShow;
            this.lblOption33.Visible = isLabelsShow;
            this.lblOption34.Visible = isLabelsShow;
            this.lblOption35.Visible = isLabelsShow;

            this.lblRemark1.Visible = isLabelsShow;
            this.lblRemark2.Visible = isLabelsShow;
            this.lblRemark3.Visible = isLabelsShow;
            this.lblRemark4.Visible = isLabelsShow;
            this.lblRemark5.Visible = isLabelsShow;
            this.lblRemark6.Visible = isLabelsShow;
            this.lblRemark7.Visible = isLabelsShow;
            this.lblRemark8.Visible = isLabelsShow;
            this.lblRemark9.Visible = isLabelsShow;
            this.lblRemark10.Visible = isLabelsShow;
            this.lblRemark11.Visible = isLabelsShow;
            this.lblRemark12.Visible = isLabelsShow;
            this.lblRemark13.Visible = isLabelsShow;
            this.lblRemark14.Visible = isLabelsShow;
            this.lblRemark15.Visible = isLabelsShow;
            this.lblRemark16.Visible = isLabelsShow;
            this.lblRemark17.Visible = isLabelsShow;
            this.lblRemark18.Visible = isLabelsShow;
            this.lblRemark19.Visible = isLabelsShow;
            this.lblRemark20.Visible = isLabelsShow;
            this.lblRemark21.Visible = isLabelsShow;
            this.lblRemark22.Visible = isLabelsShow;
            this.lblRemark23.Visible = isLabelsShow;
            this.lblRemark24.Visible = isLabelsShow;
            this.lblRemark25.Visible = isLabelsShow;
            this.lblRemark26.Visible = isLabelsShow;
            this.lblRemark27.Visible = isLabelsShow;
            this.lblRemark28.Visible = isLabelsShow;
            this.lblRemark29.Visible = isLabelsShow;
            this.lblRemark30.Visible = isLabelsShow;
            this.lblRemark31.Visible = isLabelsShow;
            this.lblRemark32.Visible = isLabelsShow;
            this.lblRemark33.Visible = isLabelsShow;
            this.lblRemark34.Visible = isLabelsShow;
            this.lblRemark35.Visible = isLabelsShow;

            // Controls
            this.txtDept.Visible = isControlsShow;
            this.dtFillDate.Visible = isControlsShow;
            this.txtFiller.Visible = isControlsShow;
            this.txtPosition.Visible = isControlsShow;

            this.rbOption1.Visible = isControlsShow;
            this.rbOption2.Visible = isControlsShow;
            this.rbOption3.Visible = isControlsShow;
            this.rbOption4.Visible = isControlsShow;
            this.rbOption5.Visible = isControlsShow;
            this.rbOption6.Visible = isControlsShow;
            this.rbOption7.Visible = isControlsShow;
            this.rbOption8.Visible = isControlsShow;
            this.rbOption9.Visible = isControlsShow;
            this.rbOption10.Visible = isControlsShow;
            this.rbOption11.Visible = isControlsShow;
            this.rbOption12.Visible = isControlsShow;
            this.rbOption13.Visible = isControlsShow;
            this.rbOption14.Visible = isControlsShow;
            this.rbOption15.Visible = isControlsShow;
            this.rbOption16.Visible = isControlsShow;
            this.rbOption17.Visible = isControlsShow;
            this.rbOption18.Visible = isControlsShow;
            this.rbOption19.Visible = isControlsShow;
            this.rbOption20.Visible = isControlsShow;
            this.rbOption21.Visible = isControlsShow;
            this.rbOption22.Visible = isControlsShow;
            this.rbOption23.Visible = isControlsShow;
            this.rbOption24.Visible = isControlsShow;
            this.rbOption25.Visible = isControlsShow;
            this.rbOption26.Visible = isControlsShow;
            this.rbOption27.Visible = isControlsShow;
            this.rbOption28.Visible = isControlsShow;
            this.rbOption29.Visible = isControlsShow;
            this.rbOption30.Visible = isControlsShow;
            this.rbOption31.Visible = isControlsShow;
            this.rbOption32.Visible = isControlsShow;
            this.rbOption33.Visible = isControlsShow;
            this.rbOption34.Visible = isControlsShow;
            this.rbOption35.Visible = isControlsShow;

            this.txtRemark1.Visible = isControlsShow;
            this.txtRemark2.Visible = isControlsShow;
            this.txtRemark3.Visible = isControlsShow;
            this.txtRemark4.Visible = isControlsShow;
            this.txtRemark5.Visible = isControlsShow;
            this.txtRemark6.Visible = isControlsShow;
            this.txtRemark7.Visible = isControlsShow;
            this.txtRemark8.Visible = isControlsShow;
            this.txtRemark9.Visible = isControlsShow;
            this.txtRemark10.Visible = isControlsShow;
            this.txtRemark11.Visible = isControlsShow;
            this.txtRemark12.Visible = isControlsShow;
            this.txtRemark13.Visible = isControlsShow;
            this.txtRemark14.Visible = isControlsShow;
            this.txtRemark15.Visible = isControlsShow;
            this.txtRemark16.Visible = isControlsShow;
            this.txtRemark17.Visible = isControlsShow;
            this.txtRemark18.Visible = isControlsShow;
            this.txtRemark19.Visible = isControlsShow;
            this.txtRemark20.Visible = isControlsShow;
            this.txtRemark21.Visible = isControlsShow;
            this.txtRemark22.Visible = isControlsShow;
            this.txtRemark23.Visible = isControlsShow;
            this.txtRemark24.Visible = isControlsShow;
            this.txtRemark25.Visible = isControlsShow;
            this.txtRemark26.Visible = isControlsShow;
            this.txtRemark27.Visible = isControlsShow;
            this.txtRemark28.Visible = isControlsShow;
            this.txtRemark29.Visible = isControlsShow;
            this.txtRemark30.Visible = isControlsShow;
            this.txtRemark31.Visible = isControlsShow;
            this.txtRemark32.Visible = isControlsShow;
            this.txtRemark33.Visible = isControlsShow;
            this.txtRemark34.Visible = isControlsShow;
            this.txtRemark35.Visible = isControlsShow;

            this.hr3.Visible = isControlsShow;
        }

        private void LoadForView(IncorruptDataSet.T_SelfControl_BusinessDataTable loadDT)
        {
            var loadRow = loadDT[0];

            this.lblDept.Text = loadRow.Dept;
            this.lblFillDate.Text = loadRow.FillDate.ToString(JCYConstant.Date_Format_CN);
            this.lblFiller.Text = loadRow.Filler;
            this.lblPosition.Text = loadRow.Position;

            this.lblOption1.Text = loadRow.Option_1;
            this.lblOption2.Text = loadRow.Option_2;
            this.lblOption3.Text = loadRow.Option_3;
            this.lblOption4.Text = loadRow.Option_4;
            this.lblOption5.Text = loadRow.Option_5;
            this.lblOption6.Text = loadRow.Option_6;
            this.lblOption7.Text = loadRow.Option_7;
            this.lblOption8.Text = loadRow.Option_8;
            this.lblOption9.Text = loadRow.Option_9;
            this.lblOption10.Text = loadRow.Option_10;
            this.lblOption11.Text = loadRow.Option_11;
            this.lblOption12.Text = loadRow.Option_12;
            this.lblOption13.Text = loadRow.Option_13;
            this.lblOption14.Text = loadRow.Option_14;
            this.lblOption15.Text = loadRow.Option_15;
            this.lblOption16.Text = loadRow.Option_16;
            this.lblOption17.Text = loadRow.Option_17;
            this.lblOption18.Text = loadRow.Option_18;
            this.lblOption19.Text = loadRow.Option_19;
            this.lblOption20.Text = loadRow.Option_20;
            this.lblOption21.Text = loadRow.Option_21;
            this.lblOption22.Text = loadRow.Option_22;
            this.lblOption23.Text = loadRow.Option_23;
            this.lblOption24.Text = loadRow.Option_24;
            this.lblOption25.Text = loadRow.Option_25;
            this.lblOption26.Text = loadRow.Option_26;
            this.lblOption27.Text = loadRow.Option_27;
            this.lblOption28.Text = loadRow.Option_28;
            this.lblOption29.Text = loadRow.Option_29;
            this.lblOption30.Text = loadRow.Option_30;
            this.lblOption31.Text = loadRow.Option_31;
            this.lblOption32.Text = loadRow.Option_32;
            this.lblOption33.Text = loadRow.Option_33;
            this.lblOption34.Text = loadRow.Option_34;
            this.lblOption35.Text = loadRow.Option_35;

            this.lblRemark1.Text = loadRow.Remark_1;
            this.lblRemark2.Text = loadRow.Remark_2;
            this.lblRemark3.Text = loadRow.Remark_3;
            this.lblRemark4.Text = loadRow.Remark_4;
            this.lblRemark5.Text = loadRow.Remark_5;
            this.lblRemark6.Text = loadRow.Remark_6;
            this.lblRemark7.Text = loadRow.Remark_7;
            this.lblRemark8.Text = loadRow.Remark_8;
            this.lblRemark9.Text = loadRow.Remark_9;
            this.lblRemark10.Text = loadRow.Remark_10;
            this.lblRemark11.Text = loadRow.Remark_11;
            this.lblRemark12.Text = loadRow.Remark_12;
            this.lblRemark13.Text = loadRow.Remark_13;
            this.lblRemark14.Text = loadRow.Remark_14;
            this.lblRemark15.Text = loadRow.Remark_15;
            this.lblRemark16.Text = loadRow.Remark_16;
            this.lblRemark17.Text = loadRow.Remark_17;
            this.lblRemark18.Text = loadRow.Remark_18;
            this.lblRemark19.Text = loadRow.Remark_19;
            this.lblRemark20.Text = loadRow.Remark_20;
            this.lblRemark21.Text = loadRow.Remark_21;
            this.lblRemark22.Text = loadRow.Remark_22;
            this.lblRemark23.Text = loadRow.Remark_23;
            this.lblRemark24.Text = loadRow.Remark_24;
            this.lblRemark25.Text = loadRow.Remark_25;
            this.lblRemark26.Text = loadRow.Remark_26;
            this.lblRemark27.Text = loadRow.Remark_27;
            this.lblRemark28.Text = loadRow.Remark_28;
            this.lblRemark29.Text = loadRow.Remark_29;
            this.lblRemark30.Text = loadRow.Remark_30;
            this.lblRemark31.Text = loadRow.Remark_31;
            this.lblRemark32.Text = loadRow.Remark_32;
            this.lblRemark33.Text = loadRow.Remark_33;
            this.lblRemark34.Text = loadRow.Remark_34;
            this.lblRemark35.Text = loadRow.Remark_35;


        }

        private void LoadForEdit(IncorruptDataSet.T_SelfControl_BusinessDataTable loadDT)
        {
            var loadRow = loadDT[0];
            this.txtDept.Text = loadRow.Dept;
            this.txtFiller.Text = loadRow.Filler;
            this.txtPosition.Text = loadRow.Position;

            this.rbOption1.SelectedValue = loadRow.Option_1;
            this.rbOption2.SelectedValue = loadRow.Option_2;
            this.rbOption3.SelectedValue = loadRow.Option_3;
            this.rbOption4.SelectedValue = loadRow.Option_4;
            this.rbOption5.SelectedValue = loadRow.Option_5;
            this.rbOption6.SelectedValue = loadRow.Option_6;
            this.rbOption7.SelectedValue = loadRow.Option_7;
            this.rbOption8.SelectedValue = loadRow.Option_8;
            this.rbOption9.SelectedValue = loadRow.Option_9;
            this.rbOption10.SelectedValue = loadRow.Option_10;
            this.rbOption11.SelectedValue = loadRow.Option_11;
            this.rbOption12.SelectedValue = loadRow.Option_12;
            this.rbOption13.SelectedValue = loadRow.Option_13;
            this.rbOption14.SelectedValue = loadRow.Option_14;
            this.rbOption15.SelectedValue = loadRow.Option_15;
            this.rbOption16.SelectedValue = loadRow.Option_16;
            this.rbOption17.SelectedValue = loadRow.Option_17;
            this.rbOption18.SelectedValue = loadRow.Option_18;
            this.rbOption19.SelectedValue = loadRow.Option_19;
            this.rbOption20.SelectedValue = loadRow.Option_20;
            this.rbOption21.SelectedValue = loadRow.Option_21;
            this.rbOption22.SelectedValue = loadRow.Option_22;
            this.rbOption23.SelectedValue = loadRow.Option_23;
            this.rbOption24.SelectedValue = loadRow.Option_24;
            this.rbOption25.SelectedValue = loadRow.Option_25;
            this.rbOption26.SelectedValue = loadRow.Option_26;
            this.rbOption27.SelectedValue = loadRow.Option_27;
            this.rbOption28.SelectedValue = loadRow.Option_28;
            this.rbOption29.SelectedValue = loadRow.Option_29;
            this.rbOption30.SelectedValue = loadRow.Option_30;
            this.rbOption31.SelectedValue = loadRow.Option_31;
            this.rbOption32.SelectedValue = loadRow.Option_32;
            this.rbOption33.SelectedValue = loadRow.Option_33;
            this.rbOption34.SelectedValue = loadRow.Option_34;
            this.rbOption35.SelectedValue = loadRow.Option_35;

            this.txtRemark1.Text = loadRow.Remark_1;
            this.txtRemark2.Text = loadRow.Remark_2;
            this.txtRemark3.Text = loadRow.Remark_3;
            this.txtRemark4.Text = loadRow.Remark_4;
            this.txtRemark5.Text = loadRow.Remark_5;
            this.txtRemark6.Text = loadRow.Remark_6;
            this.txtRemark7.Text = loadRow.Remark_7;
            this.txtRemark8.Text = loadRow.Remark_8;
            this.txtRemark9.Text = loadRow.Remark_9;
            this.txtRemark10.Text = loadRow.Remark_10;
            this.txtRemark11.Text = loadRow.Remark_11;
            this.txtRemark12.Text = loadRow.Remark_12;
            this.txtRemark13.Text = loadRow.Remark_13;
            this.txtRemark14.Text = loadRow.Remark_14;
            this.txtRemark15.Text = loadRow.Remark_15;
            this.txtRemark16.Text = loadRow.Remark_16;
            this.txtRemark17.Text = loadRow.Remark_17;
            this.txtRemark18.Text = loadRow.Remark_18;
            this.txtRemark19.Text = loadRow.Remark_19;
            this.txtRemark20.Text = loadRow.Remark_20;
            this.txtRemark21.Text = loadRow.Remark_21;
            this.txtRemark22.Text = loadRow.Remark_22;
            this.txtRemark23.Text = loadRow.Remark_23;
            this.txtRemark24.Text = loadRow.Remark_24;
            this.txtRemark25.Text = loadRow.Remark_25;
            this.txtRemark26.Text = loadRow.Remark_26;
            this.txtRemark27.Text = loadRow.Remark_27;
            this.txtRemark28.Text = loadRow.Remark_28;
            this.txtRemark29.Text = loadRow.Remark_29;
            this.txtRemark30.Text = loadRow.Remark_30;
            this.txtRemark31.Text = loadRow.Remark_31;
            this.txtRemark32.Text = loadRow.Remark_32;
            this.txtRemark33.Text = loadRow.Remark_33;
            this.txtRemark34.Text = loadRow.Remark_34;
            this.txtRemark35.Text = loadRow.Remark_35;

            this.hfEditDate.Value = loadRow.FillDate.ToString();

        }
    }
}
